package ualrcdg.client;

import java.util.ArrayDeque;
/**
 * This class uses an Array Deque to store objectives to be resolved.
 */
public class RuleResolver
{
	ArrayDeque<String> rulestack = new ArrayDeque<String>();
	/**
	 * A nullary constructor
	 */
	public RuleResolver()
	{
		
	}

	/**
	 * Checks the Array Deque for objectives
	 * @return a boolean if there are objectives
	 */
	public boolean hasObjectives()
	{
		if(rulestack.isEmpty())
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	
	/**
	 * This method adds a rule to the Array Deque
	 * @param rule to be added
	 */
	public void addRule(String rule)
	{
		rulestack.add(rule);
	}

	/**
	 * This method checks if an objective has been fulfilled
	 * @param rule
	 * @return
	 */
	public boolean checkRule(String rule) 
	{
		
		if((rule == "arrived") || (rule == "buttonpressed") || ((rule == "timecompleted") && (rule == "arrived")))
		{
			getRule();
			return true;
		}
		else
		{
			return false;
		}
	}

	public void getRule() 
	{
		rulestack.removeFirst();
	}
}
